﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    DAO_User dao_user = new DAO_User();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnDangnhap_Click(object sender, EventArgs e)
    {
        User user = new User();
        user.Account = txtDangNhap.Text;
        user.Pass = txtMatKhau.Text;
        int kq = dao_user.CheckLogin1(user);
        if (kq ==0)
        {
            Session["account"] = user.Account;
            Session["GioHang"] = null;
            Response.Redirect("index.aspx");

        }
        else
        {
            if (kq == 1)
            {
                Session["account"] = user.Account;
                Session["Admin"] = true;
                Response.Redirect("index.aspx");
            }
            else
            {
                txtError.Text = "Đăng nhập không thành công.";
            }
            
        }
    }
}